package com.hp.quartz.util;

import com.hp.common.utils.file.FileUtils;
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class MyAudioPlayer {
    private URL url;
    private AudioStream audioStream = null;
    private String classpath = "hp-quartz/src/main/resources";

    private String path="classes/static";
    public MyAudioPlayer(){
        try {
            File file = new File(classpath+"/wav/tishi.wav");
            url = file.toURI().toURL();
            InputStream inputStream = url.openStream();
            audioStream = new AudioStream(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public void play() {
        AudioPlayer.player.start(audioStream);
    }
}
